package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.domain.User;
import com.ruoyi.system.mapper.UserMapper;
import com.ruoyi.system.service.UserService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public List<User> getList() {
        LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
        wrapper.select(User::getName,User::getAge);
        return list(wrapper);
    }


    public void add(){
        User user = new User();
        user.setName("张三");
        user.setAge(18);
        save(user);
    }

    public void upd(){
        User user = new User();
        user.setName("张三");
        user.setAge(18);
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("id",1);
        update(user,wrapper);
    }

    public void del(){
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("id",1);
        remove(wrapper);
    }


}
